//
//  MeTableViewController.m
//  明和智能
//
//  Created by 李李善 on 2018/8/23.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "MeTableViewController.h"
#import "SetTableViewController.h"
#import "MeTableViewCell.h"
#import "MyDataTableViewController.h"
#import "MyJiRuTableViewController.h"
#import "MyComplaintsTableViewController.h"
#import "MyMoneyTableViewController.h"
@interface MeTableViewController ()

@end

@implementation MeTableViewController

//视图将要显示时隐藏
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
}

//视图将要消失时取消隐藏
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的";
    
}

-(void)onClickButton:(UIButton *)button
{
    switch (button.tag) {
        case 100://续费
        {
            
        }
            break;
        case 200://我的钱包
        {
            MyMoneyTableViewController*vc = [MyMoneyTableViewController new];
            vc.title = @"我的钱包";
            [self pushToVC:vc model:nil hideTabBar:YES];
        }
            break;
        case 300://我的记录
        {
            
            MyJiRuTableViewController*vc = [MyJiRuTableViewController new];
            vc.title = @"我的记录";
            [self pushToVC:vc model:nil hideTabBar:YES];
            
        }
            break;
        default://我的投诉
        {
            MyComplaintsTableViewController*vc = [MyComplaintsTableViewController new];
            vc.title = @"我的投诉";
            [self pushToVC:vc model:nil hideTabBar:YES];
        }
            break;
    }
}
-(void)onLoadViewByWillAppear:(UITableView *)view
{
    view.backgroundColor = hexCOLOR(@"ECECEC");
    [view setSeparatorMan];
}
-(void)onIconClick:(UITapGestureRecognizer *)tapGesture
{
    MyDataTableViewController*vc = [MyDataTableViewController new];
    vc.title = @"个人资料";
    [self pushToVC:vc model:nil hideTabBar:YES];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==2) {
        SetTableViewController *vc = [SetTableViewController new];
        vc.title = @"设置";
        [self pushToVC:vc model:nil hideTabBar:YES];
    }else if (indexPath.section==1)
    {
        
    }
    
}


#pragma mark - Table view data source
-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    if (indexPath.section==0) {
        if (indexPath.row==0) {
            return [MCCellInfo configForCellId:cell Class:[MeTableViewCell class] Height:kFitH(50) TableView:tableView];
        }
        return [MCCellInfo configForCellId:cell2 Class:[MeTableViewCell1 class] Height:kFitH(100) TableView:tableView];
        
    }
    return [MCCellInfo configForCellId:cell3 Class:[MeTableViewCell2 class] Height:kFitH(44) TableView:tableView];
    
}

-(id)cellInitForSourceAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0) {
        if (indexPath.row!=0) {
            return @[@{@"title":@"我的钱包",
                       @"image":@"wode_qianbao)icon",
                       @"hidden":@"0",
                       },
                     @{@"title":@"我的记录",
                       @"image":@"wode_jilu_icon",
                       @"hidden":@"1",
                       },
                     @{@"title":@"我的投诉",
                       @"image":@"wode_tousu_icon",
                       @"hidden":@"0",
                       }
                     ];
        }
        return nil;
    }
       return nil;
}

-(id)modelForIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0) {
        return nil;
    }else if (indexPath.section==1)
    {
        return @{@"title":@"意见反馈",
                 @"image":@"wode_yjfk_icon"
                 };
    }
    else
    {
        return @{@"title":@"设置",
                 @"image":@"wode_shezhi_icon"
                 };
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section==0) {
        return 2;
    }
    return 1;
}

-(void)onSetSubviewSELForCell:(BaseTableViewCell *)cell forTableView:(UITableView *)tableView forIndexPath:(NSIndexPath *)indexPath
{
    //cell.backgroundColor = [UIColor redColor];
}

-(void)onSetSubviewSELForviewHeader:(UITableViewHeaderFooterView *)view forTableView:(UITableView *)tableView forSection:(NSInteger)section
{
    if (section!=0) {
        view.backgroundColor = [UIColor clearColor];
    }
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView HeaderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    if (section==0) {
    return [MCHFViewInfo configForViewId:header1 Class:[MeTableHeaderFooterView class] Height:kFitH(180) TableView:tableView IsBian:isBiao];
    }
    return [MCHFViewInfo configForViewId:header2 Class:[BaseTableViewHeaderFooterView class] Height:kFitH(5) TableView:tableView IsBian:isBiao];
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return CGFLOAT_MIN;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
